<?php

namespace app\common\model\employ;

use app\common\model\BaseModel;

class Poster extends BaseModel
{
    protected $name = 'employ_poster';
    protected $pk = 'poster_id';

    public function bgImage()
    {
        return $this->hasOne('app\\common\\model\\file\\UploadFile', 'file_id', 'bg_image_id');
    }

    public function qrCode()
    {
        return $this->hasOne('app\\common\\model\\file\\UploadFile', 'file_id', 'qr_code_id');
    }

    public function supplier()
    {
        return $this->hasOne('app\\common\\model\\supplier\\Supplier', 'shop_supplier_id', 'shop_supplier_id')->visible(['name', 'shop_supplier_id']);
    }

    /**
     * 详情
     * @return static
     */
    public static function detail($poster_id, $with = [])
    {
        return (new static())->with($with)->find($poster_id);
    }
}